home *** CD-ROM | disk | FTP | other *** search
- Path: news.mel.aone.net.au!OzEmail!usenet
- From: tedjones@voyager.co.nz (Oliver Jones)
- Newsgroups: comp.lang.c++
- Subject: const member functions
- Date: Sat, 13 Jan 1996 14:48:39 GMT
- Organization: Ted Jones Motor Co Ltd.
- Message-ID: <4d8d8f$b30@oznet07.ozemail.com.au>
- NNTP-Posting-Host: ts1p04.net.hamilton.voyager.co.nz
- X-Newsreader: Forte Free Agent 1.0.82
-
- Email reply's please.
-
- Could someone please explain to me the significance of the "const" in
- this member function declaration.
-
- int MyFunc(const char *s) const {
- ...
- };
-
- I became aware of these when my compiler complained I couldn't call a
- non-const member function from a pointer to a const parameter class.
- eg: I couldn't do this:
-
- int MyFunc2(const TMyClass *p) {
- int i = p->MyFunc("hi");
- }
-
- I needed to add the const to the declaration above. Care to explain
- the significance and "side effects" of the const member as defined
- above.
-
- Thanks.
-
-